/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package server.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author USER
 */
@Entity
@Table(name = "ViewPhoto", catalog = "WebPhotoShare", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "ViewPhoto.findAll", query = "SELECT v FROM ViewPhoto v"),
    @NamedQuery(name = "ViewPhoto.findByPhotoID", query = "SELECT v FROM ViewPhoto v WHERE v.viewPhotoPK.photoID = :photoID"),
    @NamedQuery(name = "ViewPhoto.findByDate", query = "SELECT v FROM ViewPhoto v WHERE v.viewPhotoPK.date = :date"),
    @NamedQuery(name = "ViewPhoto.findByPhotoView", query = "SELECT v FROM ViewPhoto v WHERE v.photoView = :photoView")})
public class ViewPhoto implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ViewPhotoPK viewPhotoPK;
    @Basic(optional = false)
    @Column(name = "PhotoView", nullable = false)
    private int photoView;
    @JoinColumn(name = "PhotoID", referencedColumnName = "PhotoID", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Photo photo;

    public ViewPhoto() {
    }

    public ViewPhoto(ViewPhotoPK viewPhotoPK) {
        this.viewPhotoPK = viewPhotoPK;
    }

    public ViewPhoto(ViewPhotoPK viewPhotoPK, int photoView) {
        this.viewPhotoPK = viewPhotoPK;
        this.photoView = photoView;
    }

    public ViewPhoto(int photoID, String date) {
        this.viewPhotoPK = new ViewPhotoPK(photoID, date);
    }

    public ViewPhotoPK getViewPhotoPK() {
        return viewPhotoPK;
    }

    public void setViewPhotoPK(ViewPhotoPK viewPhotoPK) {
        this.viewPhotoPK = viewPhotoPK;
    }

    public int getPhotoView() {
        return photoView;
    }

    public void setPhotoView(int photoView) {
        this.photoView = photoView;
    }

    public Photo getPhoto() {
        return photo;
    }

    public void setPhoto(Photo photo) {
        this.photo = photo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (viewPhotoPK != null ? viewPhotoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ViewPhoto)) {
            return false;
        }
        ViewPhoto other = (ViewPhoto) object;
        if ((this.viewPhotoPK == null && other.viewPhotoPK != null) || (this.viewPhotoPK != null && !this.viewPhotoPK.equals(other.viewPhotoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "server.entity.ViewPhoto[viewPhotoPK=" + viewPhotoPK + "]";
    }

}
